<template>
  <div>
    <div class="address-box"
         v-for="(item, index) in newlist"
         :key="index">
      <div class="address-content"
           @click="gonewdetail(item)">
        <p><span class="address-content-title"></span> {{item.title}}</p>
        <!-- <p><span class="address-content-title">收货地区:</span> {{item.province}} {{item.city}} {{item.area}}</p>
        <p><span class="address-content-title">收货地址:</span> {{item.address}}</p>
        <p><span class="address-content-title">手机号码:</span> {{item.phone}}</p>
        <p><span class="address-content-title">邮政编码:</span> {{item.postalcode}}</p> -->
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'mylike',
  data () {
    return {
      // 收货地址列表
      newlist: [],
    };
  },
  created () {
    // this.loadAddress();
    this.getmylike()
  },
  computed: {
    // ...mapState(['address'])
  },
  methods: {
    gonewdetail (item) {
      // console.log(item)
      this.$router.push({
        name: 'newsdetail',
        params: { row: item }
      })
    },
    // 获取该用户收藏状态
    getmylike () {
      const api = `getmylike?users_id=${this.$store.getters.userinfo.users_id}`
      this.$axios.get(api)
        .then(res => {
          console.log('获取我的收藏', res.data)
          for (let i = 0; i < res.data.length; i++) {
            this.newlist.push(res.data[i])
          }
        })
        .catch(err => {
          console.log(err)
        })
    }
  },
};
</script>

<style scoped>
.address-box {
  padding: 15px;
  margin: 15px;
  border-radius: 5px;
  box-shadow: 0px 0px 5px #ccc;
}
.address-header {
  height: 35px;
  display: flex;
  justify-content: space-between;
  color: #232323;
  font-size: 18px;
}
.address-content {
  font-size: 14px;
  cursor: pointer;
}
.address-content-title {
  color: #999;
}
.address-action span {
  margin-left: 15px;
  font-size: 14px;
  color: #2d8cf0;
  cursor: pointer;
}
</style>